"""
pip install redis
"""

import redis


def add_name(name):
    # 连接redis，加上decode_responses=True，写入的键值对中的value为str类型，不加这个参数写入的则为字节类型
    r = redis.Redis(host='127.0.0.1', port=6379, decode_responses=True, db=0)

    r.sadd("names", "{}".format(name))
    result = r.smembers("names")
    print(result)


add_name("狗翠花")
